package b2.widget.fort
{
	import b2.net.*;
	import b2.widget.BasicButton;
	
	import flash.display.Sprite;
	import flash.events.*;
	import flash.filters.*;
	import flash.text.*;
	
	public class JoinRoomDialog extends Sprite
	{
		private var numBox:TextField;
		
		public function JoinRoomDialog()
		{
			super();
			var MessageBoxGgr:Class = ResourceHelper.getInstance().getClassByName("JoinRoomDialogBgr");
			var mainSprite:Sprite = new MessageBoxGgr();
			addChild(mainSprite);
			//标题
			var titleText:TextField = new TextField();
			titleText.selectable = false;
        	titleText.autoSize = TextFieldAutoSize.CENTER;
			titleText.defaultTextFormat = new TextFormat("微软雅黑", 12, 0xFFFFFF);
			titleText.filters = [new GlowFilter(0x000000, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			titleText.text = "房间号";
			titleText.x = (this.width - titleText.width) / 2;
			titleText.y = 10;
			addChild(titleText);
			//数字输入框
			numBox = new TextField();
			numBox.defaultTextFormat = new TextFormat("微软雅黑", 12, 0x000000);
			numBox.restrict = "0-9";
			numBox.width = 100;
			numBox.height = 20;
			numBox.x = (this.width - numBox.width) / 2;
			numBox.y = 35;
			numBox.background = true;
			numBox.type = TextFieldType.INPUT;
			addChild(numBox);
			//进入按钮
			var ButtonBgr:Class = ResourceHelper.getInstance().getClassByName("ButtonBgr0");
			var enterButton:BasicButton = new BasicButton(ButtonBgr, "进入");
			enterButton.x = (this.width - enterButton.width) / 2;
			enterButton.y = 65;
			addChild(enterButton);
			enterButton.addEventListener(MouseEvent.CLICK, onMouseClick);
		}
		
		private function onMouseClick(event:MouseEvent):void
		{
			SmartFoxHelper.getInstance().joinRoom(numBox.text);
		}
		
	}
}